<% wikis ||= @wikis #accept local if present, default to instance %>
<% if local_assigns[:digest] and wikis.size == 0 %>
  <div class="alert alert-warning" role="alert">
    You haven't subscribed to any topic yet. Visit <a href="https://publiclab.org/subscriptions">https://publiclab.org/subscriptions</a> to subscribe to more topics.
  </div>
<% else %>
  <table class="table">
    <tr>
      <th><a href = "?sort=title"> <%= translation('wiki._wikis.title') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
      <th>Image</th>
      <th><a href = "?sort=last_edited"> <%= translation('wiki._wikis.last_edited') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
      <th><a href = "?sort=edits"> <%= translation('wiki._wikis.edits') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
      <th><a href = "?sort=page_views"> <%= translation('wiki._wikis.page_views') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
      <th><a href = "?sort=likes"> <%= translation('wiki._wikis.likes') %></a> <i class="fa fa-sort" aria-hidden="true"></i></th>
    </tr>
    <% wikis.each do |wiki| %>
      <tr>
        <td style="width:50%"><i class="fa fa-file"></i> <a href="<%= wiki.path %>"><%= wiki.latest.title %></a></td>
        <td>
          <% if wiki.main_image.present? && wiki.main_image.is_image? %>
            <div style="padding-bottom: 30px;" class="rounded mx-auto d-block">
              <img src="<%= wiki.main_image.path(:default) %>" style="width:120px;border-radius:5px;">
            </div>
          <% elsif wiki.scraped_image %>
            <div style="padding-bottom:30px;" class="rounded mx-auto d-block">
              <img src="<%= wiki.scraped_image %>" style="width:120px;border-radius:5px;">
            </div>
          <% else %>
            <div>
              <p class="font-italic">None</p>
            </div>
          <% end %>
        </td>
        <td><%= distance_of_time_in_words(Time.at(wiki.latest.created_at), Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' }) %> <%= raw translation('wiki._wikis.by') %>
        <a href="/profile/<%= wiki.latest.author&.name %>"><%= wiki.latest.author&.name %></a></td>
        <td><%= wiki.revisions.size %></td>
        <td><%= number_with_delimiter(wiki.views) %></td>
        <td><%= number_with_delimiter(wiki.cached_likes) %></td>
      </tr>
    <% end %>
  </table>
<% end %>
<% if @pagy %>
  <%== pagy_bootstrap_nav @pagy %>
<% else %>
  <%= will_paginate wikis, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer if @paginated %>
<% end %>